<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('sys_permissions', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('parent_id')->default(0);
            $table->string('tree_path')->nullable()->comment('父节点ID路径');
            $table->string('name', 64)->default('')->comment('菜单名称');
            $table->tinyInteger('type')->comment('菜单类型(1:菜单 2:目录 3:外链 4:按钮 5:内链)');
            $table->string('path', 128)->default('')->comment('路由路径(浏览器地址栏路径)');
            $table->string('component', 128)->nullable()->comment('组件路径(vue页面完整路径，省略.vue后缀)');
            $table->string('perm', 128)->nullable()->comment('权限标识');
            $table->tinyInteger('visible')->default(1)->comment('显示状态(1-显示;0-隐藏)');
            $table->integer('sort')->default(0)->comment('排序');
            $table->string('icon', 64)->default('')->comment('菜单图标');
            $table->string('redirect', 128)->nullable()->comment('跳转路径');
            $table->tinyInteger('always_show')->nullable()->comment('&#8203;``【oaicite:1】``&#8203;只有一个子路由是否始终显示(1:是 0:否)');
            $table->tinyInteger('keep_alive')->nullable()->comment('&#8203;``【oaicite:0】``&#8203;是否开启页面缓存(1:是 0:否)');
            $table->timestamps();

        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('sys_permissions');
    }
};
